<?php
class PhpQRCode{
    
	//processing form input
	//remember to sanitize user input in real-life solution !!!
	private $errorCorrectionLevel = 'L';		// L M Q H
	private $matrixPointSize = 8;				// 1 2 3 4 5 6 7 8 9 10
	private $date = 'jjmobi';
	private $pngTempDir		= '';
	private $pngTempName    = '';
	public function set($key,$value){
		$this->$key = $value;
	}
	public function __construct() {
	    include "qrlib.php";
	}
    public function init(){
	    //ofcourse we need rights to create temp dir
	    if (!file_exists($this->pngTempDir))
	        mkdir($this->pngTempDir);
	
	    if ($this->date != 'jjmobi') {
	        // user data
	        if ($this->pngTempName != '') {
	            $filename = $this->pngTempDir.$this->pngTempName;
	        } else {
	           $filename = $this->pngTempDir.'test'.md5($this->date.'|'.$this->errorCorrectionLevel.'|'.$this->matrixPointSize).'.png';
	        }
	        QRcode::png($this->date, $filename, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
	    } else {
	        //default data
	        QRcode::png('', $filename, $this->errorCorrectionLevel, $this->matrixPointSize, 2);
	    }
	    //display generated file
	    return basename($filename);
	    QRtools::timeBenchmark();    
	}
}